﻿namespace Acl.Messages.Impl;

internal static class PublishOptionsExtensions
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="ops"></param>
    /// <returns></returns>
    public static (NatsPubOpts?,NatsHeaders?,string? replyTo) ToNatsPubOps(this DistributionPublishOptions? ops)
    {
        if (ops is null) return default;

        NatsHeaders? headers = ops.Value.Headers != null ? new NatsHeaders(ops.Value.Headers) : default;


        return (new NatsPubOpts {  WaitUntilSent = ops.Value.WaitUntilSent, ErrorHandler = ops.Value.ErrorHandler }, headers, ops?.ReplyTo);
    }
}